#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxm=23, maxk=12;

int min(int a, int b) {
	return a<b ? a : b;
}

int main() {
	freopen("transfer.in", "r", stdin);
	freopen("transfer.out", "w", stdout);

	static int f[1<<maxm], g[maxm+1][1<<maxk], h[maxm+1][1<<maxk], rec[1<<maxm], cnt[1<<maxm], map[maxm+1][maxm+1];
	int n, m, k, last, t;
	scanf("%d %d %d", &n, &m, &k);
	scanf("%d", &last);
	for (int i=2; i<=n; i++) {
		scanf("%d", &t);
		map[last][t]++;
		last = t;
	}

	for (int i=1; i<=m; i++) {
		rec[1<<(i-1)] = i;
	}
	for (int i=1; i<=m; i++) {
		for (int j=1; j<=maxk; j++){
			if (i!=j) {
				g[i][0] += map[j][i]*k-map[i][j];
			}
		}
		for (int j=maxk+1; j<=m; j++) {
			if (i!=j) {
				h[i][0] += map[j][i]*k-map[i][j];
			}
		}
		for (int j=1; j<(1<<maxk); j++) {
			int t=(j-1)&j, o=rec[j-t];
			if (i!=o) {
				g[i][j] = g[i][t]+map[i][o]-map[o][i]*k+map[o][i]+map[i][o]*k;
			}
			if (i!=o+maxk && o+maxk<=m) {
				h[i][j] = h[i][t]+map[i][o+maxk]-map[o+maxk][i]*k+map[o+maxk][i]+map[i][o+maxk]*k;
			}
		}
	}

	memset(f, 127, sizeof f);
	f[0] = 0;
	for (int i=1; i<(1<<m); i++) {
		cnt[i] = cnt[i>>1]+(i&1);
		for (int j=1; j<=m; j++) {
			if ((i>>(j-1))&1) {
				int s=i-(1<<(j-1));
				f[i] = min(f[i], f[s]+(g[j][s&0xfff]+h[j][s>>maxk])*cnt[i]);
			}
		}
	}

	printf("%d", f[(1<<m)-1]);

	fclose(stdin);
	fclose(stdout);
	return 0;
}
